package de.szut.dqi12.sqlitebrowser.controller;

import de.szut.dqi12.sqlitebrowser.view.View;

/**
 * GUIController
 * Controls the GUI
 * @author Alexander
 */

public class GUIController {

	private static GUIController instance;
	private Controller controller;
	private View gui;
	
	/**
	 * Private constructor -> Singleton Patter
	 * @param gui - View instance
	 */
	private GUIController(View gui) {
		this.gui = gui;
	}
	
	/**
	 * Singleton Patter getInstance Method
	 * @return Instance of the GUIController class
	 */
	
	public static GUIController getInstance(View gui) {
		if(instance == null) {
			instance = new GUIController(gui);
		}
		return instance;
	}
	
	/**
	 * Singleton Patter getInstance Method
	 * @return Instance of the Controller class
	 */
		
	public static GUIController getInstance() {
		return instance;
	}
	
	/**
	 * Gets an instance of the controller class
	 * @return - Instance of the controller class
	 */
	
	public Controller getController() {
		controller = Controller.getInstance();
		return controller;
	}
	
	/**
	 * Gets an instance of the view class
	 * @return - Instance of the view class
	 */
	
	public View getView() {
		return gui;
	}
	
	/**
	 * Calls the executeErrorMessageDialog method of the View to display an Error
	 * @param errorMessage - Error message
	 */
	
	public void executeErrorMessageDialog(String errorMessage) {
		gui.executeErrorMessageDialog(errorMessage);
	}

	
}

